/**
 * Project Name:AccessTokenController.java
 * File Name:AccessTokenController.java
 * Date:2018年06月05日 11:38
 * Copyright (c) 2018, zhang.xiangyu@foxmail.com All Rights Reserved.
 */
package com.dyrj.api.login.controller;

import com.dyrj.api.login.params.AccessTokenParams;
import com.dyrj.api.login.params.VerifyAccessTokenParams;
import com.dyrj.api.login.service.AccessTokenService;
import com.dyrj.component.OperateLog;
import com.dyrj.vo.TokenResultMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Title: LoginApiController
 * @Description: todo(登陆)
 * @Author
 * @Date 2018年06月05日 11:32
 * @Version V1.0
 */
@RestController
@RequestMapping("/api/token")
@Api(value="AccessTokenController",description="监测系统的权限控制接口。", tags = {"01_权限认证接口"})
class AccessTokenController {
	@Resource
	private AccessTokenService service;

	/**
	 * @Title: validate
	 * @Description: todo(验证用户，并返回token)
	 * @Params: [user]
	 * @Return com.dyrj.vo.ResultMsg    返回类型
	 * @Author
	 * @Date 2018年06月05日 14:18
	 */
	@ApiOperation(value = "获取access_token", notes = "获取权限认证令牌")
	@OperateLog("获取access_token")
	@PostMapping("/getaccesstoken")
	public TokenResultMsg getAccessToken(@RequestBody AccessTokenParams params) throws Exception {
		return service.getAccessToken(params);
	}

	/**
	 * @Title: verifyAccessToken
	 * @Description: todo(验证权限)
	 * @Params: [token]
	 * @Return     返回类型
	 * @Author
	 * @Date 2018年06月11日 21:02
	 */
	@ApiOperation(value = "验证access_token", notes = "验证权限令牌")
	@OperateLog("验证access_token")
	@PostMapping ("/verifyAccess_token")
	public TokenResultMsg verifyAccessToken(@RequestBody VerifyAccessTokenParams record) throws Exception {
		return service.verifyAccessToken(record);
	}
}
  